package model;

/**
 * Created by eleven on 16/1/7.
 */
public class ServiceModel {

    public String Service(String name, String daoname){
        String text =
                "     /**\n" +
                "     * "+name+"\n" +
                "     * @param begin\n" +
                "     * @param end\n" +
                "     * @return\n" +
                "     */\n" +
                "    List<"+daoname+"> get"+daoname+"(Date begin, Date end);";
        return text;
    }

    public String ServiceImpl(String name, String daoname){
        String smalldaoname = daoname.substring(0,1).toLowerCase()+daoname.substring(1);
        String text =
                "    @Autowired\n" +
                "    private "+daoname+" "+smalldaoname+"Mapper;\n" +
                "\n" +
                "    /**\n" +
                "     * "+name+"\n" +
                "     * @param begin\n" +
                "     * @param end\n" +
                "     * @return\n" +
                "     */\n" +
                "    @Override\n" +
                "    public List<"+daoname+"> get"+daoname+"(Date begin, Date end) {\n" +
                "        "+daoname+"Criteria criteria = new "+daoname+"Criteria();\n" +
                "        "+daoname+"Criteria.Criteria "+smalldaoname+"Criteria = criteria.createCriteria().andDayKeyBetween(begin, end);\n" +
                "        criteria.setOrderByClause(\"day_key desc\");\n" +
                "        return "+smalldaoname+"Mapper.selectByExample(criteria);\n" +
                "    }";
        return text;
    }

}
